<html>
<head><meta charset="utf-8"><title>is apply_switch_int_edge_effects ready to be used? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html">is apply_switch_int_edge_effects ready to be used?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221264673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221264673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Youren Shen <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221264673">(Dec 31 2020 at 02:43)</a>:</h4>
<p>It's looks useful to track different branch in MIR. But it's not public to other crates. Also, if switch_int_edge is more effective to track edge, should we add similar things to apply_call_return_effect or apply_call_unwind_effect to track different edge from call?</p>



<a name="221313331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221313331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221313331">(Dec 31 2020 at 20:09)</a>:</h4>
<p><span class="user-mention" data-user-id="309012">@Youren Shen</span> I designed that interface but I don't understand what you're asking. <code>SwitchInt</code> edge effects are currently used in the compiler to propagate the initialized-ness of enum variants, so they're "ready" in that sense.</p>



<a name="221313500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221313500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221313500">(Dec 31 2020 at 20:12)</a>:</h4>
<p>The reason to have a separate interface for "call return" effects is because we can be more efficient when running dataflow if we know that only one outgoing edge has an effect. That's why there's no <code>apply_call_unwind_effect</code>.</p>



<a name="221332458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221332458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Youren Shen <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221332458">(Jan 01 2021 at 03:12)</a>:</h4>
<p>Sorry for the unclear about my question. <br>
I was trying to use  apply_switch_int_edge_effects in my analysis crate. But the trait SwitchIntEdgeEffects and the struct SwitchIntTarget is private.  It seems I can't define my own apply_switch_int_edge_effects in my crate without import them.</p>
<p>Perhaps I'm wrong about how to use it. :D There is no example about how to use this function in the compiler.</p>



<a name="221332588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221332588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Youren Shen <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221332588">(Jan 01 2021 at 03:17)</a>:</h4>
<p>In my case, I want to track every branch, take the effect whether they goto yes or no. SwithInt is a great function to track different edge from the SwithInt terminator. I also want to apply the similar analysis to call/unwind or any other BasicBlock that have different out edges.</p>



<a name="221334218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/is%20apply_switch_int_edge_effects%20ready%20to%20be%20used%3F/near/221334218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/is.20apply_switch_int_edge_effects.20ready.20to.20be.20used.3F.html#221334218">(Jan 01 2021 at 04:13)</a>:</h4>
<p>Ah, yes it's fine to use it outside <code>rustc_mir</code>. I'm surprised if it's not crate-public, but IIRC there's some re-exports that I forgot to remove that might be accidentally subverting the "private type in public interface" warning.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>